import { defineStore } from "pinia";
import type { Tab,TypeLayoutSetting } from "@/types/store"

const useLayoutSettingStore = defineStore('LayoutSettingStore', {
    state: ():TypeLayoutSetting => {
        return {
            collapse: false, // header中隐藏/显示菜单信息
            tabs:[]  //多tab页
        }
    },
    getters: {
        getCollapse(state) {
            return state.collapse
        }
    },
    actions: {
        setCollapse(collapse: boolean) {
            this.collapse = collapse
        }, 
        // 添加选项卡
        addTab(tab:Tab){
           // 判断数据是否已经存在于选项卡里面
           if(this.tabs.some(item=>item.path === tab.path)){
            return
           }
            this.tabs.push(tab)     
        }
    }
})
export default useLayoutSettingStore